package com.cc.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.charset.Charset;
import java.util.List;

/**
 * @author CC
 * @version 1.0
 * @description: TODO
 * @date 2025/6/16 11:10
 */
@Configuration
@ComponentScan("com.cc.controller")
@EnableWebMvc // 开启SpringMVC的功能
public class SpringMVCConfig implements WebMvcConfigurer {
    // 配置消息转换器
    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
        stringConverter.setDefaultCharset(Charset.forName("UTF-8"));
        converters.add(0,stringConverter);

    }
}
